<% content_for :subnav do %>
<div class="reader-navbar versions-navbar">
  <div class="container">
    <div class="navbar-title">
      <span class="hide-sm">
        <a href="<%= @doc.to_path %>" title="<%= @doc.title %>"><%= truncate @doc.title, length: 25 %></a>
        <span class= "divider">/</span>
        <span class="doc-title"><%= t(".Versions") %></span>
      </span>
    </div>

    <div class="navbar-buttons d-flex flex-items-center">
      <%= form_with(model: @doc, url: revert_user_repository_doc_path(@user, @repository, @doc),
        local: true, remote: true) do |form| %>
        <input type="hidden" name="version_id">
        <button type="submit" disabled class="btn btn-sm btn-primary btn-revert"><%= t(".Revert") %></button>
        <%= link_to t(".Cancel"), @doc.to_path, class: "btn btn-sm mr-2" %>
      <% end %>
      <span class="diff-toggle">
        <label for="version-diff-toggle">
          <input type="checkbox" id="version-diff-toggle">
          <%= t(".Diff mode") %>
        </label>
      </span>
    </div>
  </div>
</div>
<% end %>

<div class="doc-page d-flex">
  <div class="doc-sidebar version-sidebar">
    <%= render partial: "versions/version", locals: { version: @current_version, current: true } %>
    <div class="version-items" data-selected-id="<%= @current_version.id %>">
      <%= render "versions" %>
    </div>
  </div>
  <div id="previus-version-content" style="display: none">
    <%= raw(@previous_version&.body_html || "") %>
  </div>
  <div class="doc-main main-content flex-auto">
    <h1 class="doc-title"><%= @doc.title %></h1>
    <div class="version-preview">
      <div class="markdown-body">
        <%= raw @current_version.body_html %>
      </div>
    </div>
    <div class="version-diff" style="display: none"><div class="markdown-body"></div></div>
  </div>
</div>
